#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using Microsoft.Reporting.WebForms;

#endregion

namespace PLACEHR.Web.Categories.Report
{
    public partial class StaffSalaryPrintControl : UserControl
    {
        public StaffSalaryPrintControl()
        {
            InitializeComponent();
        }

        private void reportViewer1_HostedPageLoadComplete(object sender, Gizmox.WebGUI.Forms.Hosts.AspPageEventArgs e)
        {
            reportViewer1.ProcessingMode = ProcessingMode.Remote;
            reportViewer1.ServerReport.ReportServerUrl = new Uri(string.Format("http://localhost/ReportServer"));
            reportViewer1.ServerReport.ReportPath = string.Format("/PlaceHR.Report/PrintSalaryListReport");

            if (Global.CurrentUser.RoleID == 2 || Global.CurrentUser.RoleID == 3)
            {
                ReportParameterInfoCollection c = reportViewer1.ServerReport.GetParameters();
                if (c.Any(o => o.Name == "OfficeCode" && o.Visible == false))
                {
                    return;
                }
                else
                {
                    var reportParams = new ReportParameter();
                    reportParams.Name = "OfficeCode";
                    reportParams.Visible = false;
                    reportParams.Values.Add(Global.CurrentUser.OfficeDepartment_lnk.Select(o => o.OfficeCode).FirstOrDefault());

                    reportViewer1.ServerReport.SetParameters(reportParams);
                }
            }
        }
    }
}